﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Wpf_ClientLeger.BusinessObject;

namespace Wpf_ClientLeger.IHM
{
    /// <summary>
    /// Logique d'interaction pour MenuPrincipal.xaml
    /// </summary>
    public partial class MenuPrincipal : Window
    {

        Parametres paramAppli;
        User currentUser;

        public MenuPrincipal(Parametres param, User user)
        {
            InitializeComponent();
            paramAppli = param;
            currentUser = user;
            this.lbl_nom.Content = user.preUser + " " + user.nomUser;

            //On récupère les confidentialités du user 
            foreach (int userParam in user.confUser)
            {
                if (userParam == param.id_confAdminBP)
                {
                    bt_preparation.IsEnabled = true;
                    bt_reception.IsEnabled = true;
                }
                else if (userParam == param.id_confPrepa)
                {
                    bt_preparation.IsEnabled = true;
                }
                else if (userParam == param.id_confCmd)
                {
                    
                }
                else if (userParam == param.id_confRecep)
                    bt_reception.IsEnabled = true;
            }
        }

        /// <summary>
        /// Clic sur le bouton "déconnexion", ferme l'application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        //appel de l'écran préparation
        private void bt_preparation_Click(object sender, RoutedEventArgs e)
        {
            Preparation_Menu menuPrep = new Preparation_Menu(paramAppli, currentUser);
            menuPrep.Show();
            this.Close();
        }

        //appel de l'écran réception
        private void bt_reception_Click(object sender, RoutedEventArgs e)
        {

        }

        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                this.Close();
            }
        }
    }
}
